package org.sgr.money.manager.frame;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.swt.graphics.Image;

public class MmgrFrame {

	private Shell sShell = null;
	private Menu menuBar = null;
	private Menu submenuMyAcct = null;
	private ToolBar toolBar = null;
	/**
	 * This method initializes toolBar	
	 *
	 */
	private void createToolBar() {
		toolBar = new ToolBar(sShell, SWT.NONE);
		ToolItem toolItemSubjectMgr = new ToolItem(toolBar, SWT.PUSH);
		toolItemSubjectMgr.setText("科目维护");
		toolItemSubjectMgr.setImage(new Image(Display.getCurrent(), getClass().getResourceAsStream("/subject.jpg")));
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		/* Before this is run, be sure to set up the launch configuration (Arguments->VM Arguments)
		 * for the correct SWT library path in order to run with the SWT dlls. 
		 * The dlls are located in the SWT plugin jar.  
		 * For example, on Windows the Eclipse SWT 3.1 plugin jar is:
		 *       installation_directory\plugins\org.eclipse.swt.win32_3.1.0.jar
		 */
		Display display = Display.getDefault();
		MmgrFrame thisClass = new MmgrFrame();
		thisClass.createSShell();
		thisClass.sShell.open();

		while (!thisClass.sShell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}

	/**
	 * This method initializes sShell
	 */
	private void createSShell() {
		sShell = new Shell();
		sShell.setText("money manager");
		createToolBar();
		sShell.setSize(new Point(600, 400));
		sShell.setLayout(new FormLayout());
		menuBar = new Menu(sShell, SWT.BAR);
		MenuItem submenuItemMyAcct = new MenuItem(menuBar, SWT.CASCADE);
		submenuItemMyAcct.setText("我的账户");
		submenuMyAcct = new Menu(submenuItemMyAcct);
		MenuItem pushOverview = new MenuItem(submenuMyAcct, SWT.PUSH);
		pushOverview.setText("概况");
		submenuItemMyAcct.setMenu(submenuMyAcct);
		sShell.setMenuBar(menuBar);
	}

}
